<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Produk extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->model('Produk_model');
		$this->load->model('Order_model');
		$this->load->library('session');
		$this->load->helper('url');
		$this->load->helper('bantuan_helper');
		$this->load->helper('topkonten_helper');
		$this->load->library('pagination');
		
	}
	

	function index()
	{
	
		$data['current2'] = 'current'; // FOR MENU
		$this->load->library('pagination');
		$config['base_url'] = site_url().'/produk/index';
		$config['total_rows'] = count($this->Produk_model->getProduk('AllNew',FALSE,FALSE,FALSE));
		$config['per_page'] = 8;
		$config['uri_segment'] = 3;
		$config['next_link'] = '&raquo;';
		$config['prev_link'] = '&laquo;';
		$this->pagination->initialize($config);
		$data['title'] = 'Home';
		$data['cumb'] = anchor('produk','<strong>Home<strong>');
		$data['ses_id'] = $this->session->userdata('session_id');
		$data['res_promo'] = $this->Produk_model->getProduk('promo_depan',FALSE,FALSE,FALSE);
		$data['arr_produk'] = $this->Produk_model->getProduk('AllNew',FALSE,$config['per_page'],$this->uri->segment(3));
		$data['main_view'] = 'home';
		$this->load->view('/index',$data);
	
	}
    // GET THE LINK OF KATEGORI
    function parent_kat_slug($id_kat1){
            $qr1 = FALSE;
            $qr2 = FALSE;
            $qr3 = FALSE;
            // first_parent
            $this->db->select('kategori_id,nama_kategori,parent_kat_id');
            $this->db->where('kategori_id',$id_kat1);
            $qr1 = $this->db->get('tb_kat_produk')->row();
            
            // second parent
            if ($qr1->parent_kat_id != 0){
                $this->db->select('kategori_id,nama_kategori,parent_kat_id');
                $this->db->where('kategori_id',$qr1->parent_kat_id);
                $qr2 = $this->db->get('tb_kat_produk')->row();
                
                     if ($qr2->parent_kat_id != 0){
                        $this->db->select('kategori_id,nama_kategori,parent_kat_id');
                        $this->db->where('kategori_id',$qr2->parent_kat_id);
                        $qr3 = $this->db->get('tb_kat_produk')->row();
                                 
                     }
            }

           
            if(($qr1 == TRUE) && ($qr3 == FALSE) && ($qr3 == FALSE)){
                $slug = $qr1->nama_kategori;
                return $slug; 
            }
            
            if(($qr1 == TRUE) && ($qr3 == TRUE) && ($qr3 == FALSE)){
               /*
                $slug = anchor('produk/kategori/'.$qr3->kategori_id,'<strong>'.$qr3->nama_kategori.'</strong>').' &raquo; '.
                       anchor('produk/kategori/'.$qr2->kategori_id,'<strong>'.$qr2->nama_kategori.'</strong>');
               */
                $slug = '<strong>'.$qr3->nama_kategori.'</strong> &raquo;'.$qr2->nama_kategori;
                
                return $slug; 
            }
            if(($qr1 == TRUE) && ($qr3 == TRUE) && ($qr3 == TRUE)){
                
                $slug = '<strong>'.$qr3->nama_kategori.'</strong> &raquo; <strong>'.$qr2->nama_kategori.'</strong> &raquo; '.$qr1->nama_kategori;
                return $slug; 
            }
            
            
        }

/* =========================================================== KATEGORI CONTROL ================================================================*/		
	function kategori()
	{
		$data['current2'] = 'current'; // FOR MENU
/* ==================================================== NON PAGINATION ===========================================================================*/
        if(!$this->uri->segment(6)):
			$id_kat   = $this->uri->segment(4);
			$id_brand = $this->uri->segment(3);
	
			// GET KATEGORI 
			$this->db->where('kategori_id',$id_kat);
			$query = $this->db->get('tb_kat_produk');
			$row = $query->row();
			
			// GET BRAND
			$this->db->where('brand_id',$row->brand_id);
			$row_brand = $this->db->get('tb_brand')->row();
			
			$qr = $this->db->get('tb_brand');
			$data['arr_brand'] = $qr->result_array();
		
			// HARD CODED FOR SLACKERS PRODUK
			if ($row->brand_id == 1):
				$data['page'] = 'produk_slaker';
			else:
				$data['page'] = 'produk';
				$data['brand_id'] = $row->brand_id;
			endif;
			
			$this->load->library('pagination');
			$offset = $this->uri->segment(6);
			$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/index/';
			$config['total_rows'] = count($this->Produk_model->getProduk('AllByCat',FALSE,$id_kat,$id_brand,FALSE,FALSE));
			$config['per_page'] = 12;
			$config['uri_segment'] = 6;
			$config['next_link'] = '&raquo;';
			$config['prev_link'] = '&laquo;';
			$this->pagination->initialize($config);
			$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.anchor('produk/brand/'.$row->brand_id,'<strong>'.$row_brand->nama_brand.'</strong>').' &raquo; '.$this->parent_kat_slug($id_kat);
			$data['title'] = $row->nama_kategori;
			// SET KEY TO ZERO
			$data['key'] = 0;
			// LINK use AJAX
			$data['link'] = 'produk_kategori_'.$id_brand.'_'.$id_kat.'_'.alias($row->nama_kategori);	
			$data['arr_produk'] = $this->Produk_model->getProduk('AllByCat',FALSE,$id_kat,$id_brand,$config['per_page'],$offset);
			$data['main_view'] = 'slak/kategori';
			$this->load->view('slak/index',$data);

/* ===================================== PAGINATION WITHOUT FILTER ===========================================================================*/
        else:
            if($this->uri->segment(6) == 'index'):
				$id_kat   = $this->uri->segment(4);
				$id_brand = $this->uri->segment(3);
					
				// kategori
				$this->db->where('kategori_id',$id_kat);
				$query = $this->db->get('tb_kat_produk');
				$row = $query->row();
					
				// brand
				$this->db->where('brand_id',$row->brand_id);
				$row_brand = $this->db->get('tb_brand')->row();
					
				$qr = $this->db->get('tb_brand');
				$data['arr_brand'] = $qr->result_array();
				
				// HARD CODED FOR SLACKERS PRODUK
				if ($row->brand_id == 1):
					$data['page'] = 'produk_slaker';
				else:
					$data['page'] = 'produk';
					$data['brand_id'] = $row->brand_id;
				endif;
					
                $this->load->library('pagination');
                $offset = $this->uri->segment(7);
                $config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/index/';
                $config['total_rows'] = count($this->Produk_model->getProduk('AllByCat',FALSE,$id_kat,$id_brand,FALSE,FALSE));
                $config['per_page'] = 12;
                $config['uri_segment'] = 7;
                $config['next_link'] = '&raquo;';
                $config['prev_link'] = '&laquo;';
                $this->pagination->initialize($config);
                    
				$data['key'] = 0;
				// LINK use AJAX
				
				$data['link'] = 'produk_kategori_'.$id_brand.'_'.$id_kat.'_'.alias($row->nama_kategori);

                $data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.anchor('produk/brand/'.$row->brand_id,'<strong>'.$row_brand->nama_brand.'</strong>').' &raquo; '.$this->parent_kat_slug($id_kat);
                $data['title'] = $row->nama_kategori;

                $data['arr_produk'] = $this->Produk_model->getProduk('AllByCat',FALSE,$id_kat,$id_brand,$config['per_page'],$offset);
                $data['main_view'] = 'slak/kategori';
                $this->load->view('slak/index',$data);

/* ===================================== CONTROL THE FILTER BY PRICE RANGE ============================================================*/			
            elseif($this->uri->segment(6) == 'price_range'):
                $id_kat   = $this->uri->segment(4);
                $id_brand = $this->uri->segment(3);
                $filter_name = $this->uri->segment(6);
                $filter_var = $this->uri->segment(7);
                $order_by = $this->uri->segment(8);
                
				// GO TO FILTER FUNCTION
                if(!$order_by):
                    $this->filter($filter_name,$filter_var,$id_kat,$id_brand,FALSE);
                else:
                    $this->filter($filter_name,$filter_var,$id_kat,$id_brand,$order_by);
                endif;

/* ===================================== CONTROL THE FILTER BY SHOPPING PROGRAM ============================================================*/					
			elseif($this->uri->segment(6) == 'shopping_program'):

				$id_kat   = $this->uri->segment(4);
                $id_brand = $this->uri->segment(3);
                $filter_name = $this->uri->segment(6);
                $filter_var = $this->uri->segment(7);
                $order_by = $this->uri->segment(8);
				
				// GO TO FILTER FUNCTION
				if(!$order_by):
                    $this->filter($filter_name,$filter_var,$id_kat,$id_brand,FALSE);
                else:
                    $this->filter($filter_name,$filter_var,$id_kat,$id_brand,$order_by);
                endif;

/* ===================================== CONTROL THE FILTER BY COLLECTION ======================================================================*/					
			elseif($this->uri->segment(6) == 'collection'):
				$id_kat   = $this->uri->segment(4);
                $id_brand = $this->uri->segment(3);
                $filter_name = $this->uri->segment(6);
                $filter_var = $this->uri->segment(7);
                $order_by = $this->uri->segment(8);
				
				// GO TO FILTER FUNCTION
				if(!$order_by):
                    $this->filter($filter_name,$filter_var,$id_kat,$id_brand,FALSE);
                else:
                    $this->filter($filter_name,$filter_var,$id_kat,$id_brand,$order_by);
                endif;
            endif;      
        endif;
	}

	
/* =========================================================== BRAND CONTROL =====================================================================*/		
	function brand()
	{
		$data['current2'] = 'current'; // FOR MENU
/* =========================================================== NON PAGINATION ================================================================*/		
		if(!$this->uri->segment(4)):
			$brand_id=$this->uri->segment(3);
			
			$this->db->where('brand_id',$brand_id);
			$query = $this->db->get('tb_brand');
			$row = $query->row();
		
			$this->load->library('pagination');
			$offset = $this->uri->segment(5);
			$config['base_url'] = site_url().'produk/brand/'.$brand_id.'/index/';
			$config['total_rows'] = count($this->Produk_model->getProduk('AllByBrand',FALSE,FALSE,$brand_id,FALSE,FALSE));
			$config['per_page'] = 12;
			$config['uri_segment'] = 4;
			$config['next_link'] = '&raquo;';
			$config['prev_link'] = '&laquo;';
			$this->pagination->initialize($config);
			$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.$row->nama_brand;
			$data['title'] = $row->nama_brand;
			
			$data['key'] = 0;
			
			// LINK use AJAX
		
			$data['link'] = 'produk_brand_'.$brand_id;
			
			$qr = $this->db->get('tb_brand');
			$data['arr_brand'] = $qr->result_array();
			
			// HARD CODED FOR SLACKERS PRODUK
			if ($row->brand_id == 1):
				$data['page'] = 'produk_slaker';
			else:
				$data['page'] = 'produk';
				$data['brand_id'] = $row->brand_id;
			endif;
			$data['arr_produk'] = $this->Produk_model->getProduk('AllByBrand',FALSE,FALSE,$brand_id,$config['per_page'],$offset);
			$data['main_view'] = 'slak/brand';
			$this->load->view('slak/index',$data);
	
		else:
/* =========================================================== PAGINATION WITHOUT CONTROL ================================================================*/		
            if($this->uri->segment(4) == 'index'):
                $brand_id=$this->uri->segment(3);
			
				$this->db->where('brand_id',$brand_id);
				$query = $this->db->get('tb_brand');
				$row = $query->row();
			
				$this->load->library('pagination');
				$offset = $this->uri->segment(5);
				$config['base_url'] = site_url().'produk/brand/'.$brand_id.'/index/';
				$config['total_rows'] = count($this->Produk_model->getProduk('AllByBrand',FALSE,FALSE,$brand_id,FALSE,FALSE));
				$config['per_page'] = 12;
				$config['uri_segment'] = 5;
				$config['next_link'] = '&raquo;';
				$config['prev_link'] = '&laquo;';
				$this->pagination->initialize($config);
				$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.$row->nama_brand;
				$data['title'] = $row->nama_brand;
				
				$data['key'] = 0;
				
				// LINK use AJAX
				$data['link'] = 'produk_brand_'.$brand_id;
				
				$qr = $this->db->get('tb_brand');
				$data['arr_brand'] = $qr->result_array();
				
				// HARD CODED FOR SLACKERS PRODUK
				if ($row->brand_id == 1):
					$data['page'] = 'produk_slaker';
				else:
					$data['page'] = 'produk';
					$data['brand_id'] = $row->brand_id;
				endif;
				$data['arr_produk'] = $this->Produk_model->getProduk('AllByBrand',FALSE,FALSE,$brand_id,$config['per_page'],$offset);
				$data['main_view'] = 'slak/brand';
				$this->load->view('slak/index',$data);

/* ===================================== CONTROL THE FILTER BY PRICE RANGE ============================================================*/			
            elseif($this->uri->segment(4) == 'price_range'):
                $id_brand = $this->uri->segment(3);
                $filter_name = $this->uri->segment(4);
                $filter_var = $this->uri->segment(5);
                $order_by = $this->uri->segment(6);
				$offset = $this->uri->segment(7);
				$order_by2 = $this->uri->segment(8);
                // go to filter function
                if($order_by == 'index'):
					if(!$offset):
						$this->filter($filter_name,$filter_var,FALSE,$id_brand,FALSE);
					else:
						$this->filter($filter_name,$filter_var,FALSE,$id_brand,$order_by);
					endif;
                else:
                    $this->filter($filter_name,$filter_var,FALSE,$id_brand,$order_by);
                endif;

/* ===================================== CONTROL THE FILTER BY SHOPPING PROGRAM ============================================================*/			
			elseif($this->uri->segment(4) == 'shopping_program'):
                $id_brand = $this->uri->segment(3);
                $filter_name = $this->uri->segment(4);
                $filter_var = $this->uri->segment(5);
                $order_by = $this->uri->segment(6);
					// go to filter function
				if(!$order_by):
                    $this->filter($filter_name,$filter_var,FALSE,$id_brand,FALSE);
                else:
                    $this->filter($filter_name,$filter_var,FALSE,$id_brand,$order_by);
                endif;
                   
/* ===================================== CONTROL THE FILTER BY COLLECTION ============================================================*/			
			elseif($this->uri->segment(4) == 'collection'):
                $id_brand = $this->uri->segment(3);
                $filter_name = $this->uri->segment(4);
                $filter_var = $this->uri->segment(5);
                $order_by = $this->uri->segment(6);
					// go to filter function
				if(!$order_by):
                    $this->filter($filter_name,$filter_var,FALSE,$id_brand,FALSE);
                else:
                    $this->filter($filter_name,$filter_var,FALSE,$id_brand,$order_by);
                endif;
                    
            endif;
        endif;
	}
	
	

/* ============================ FILTER FUNCTION TO SHORTING COMPLETE WITH PAGINATION =======================================================*/
	   
    function filter($filter_name,$filter_var_key,$id_kat=FALSE,$id_brand,$order_by = FALSE) {
		$data['current2'] = 'current'; // FOR MENU
		
/* ============================ FILTER FUNCTION TO SHORTING PRICE RANGE COMPLETE WITH PAGINATION =======================================================*/
		if($filter_name == 'price_range'):
/* ============================ FILTER FUNCTION TO SHORTING PRICE RANGE COMPLETE WITH PAGINATION FOR BRAND =======================================================*/
			if(!$id_kat): 
				// brand
				$this->db->where('brand_id',$id_brand);
				$row_brand = $this->db->get('tb_brand')->row();
				
				$qr = $this->db->get('tb_brand');
				$data['arr_brand'] = $qr->result_array();

				// HARD CODED FOR SLACKERS PRODUK
				if ($id_brand == 1):
						$data['page'] = 'produk_slaker';
				else:
						$data['page'] = 'produk';
						$data['brand_id'] = $id_brand;
				endif;
				
				// explode filter to get key short from helper
				$k = explode('_', $filter_var_key);
				
				$key = $k[0];
				
				// load to view data
				$data['key'] = $key;
				
				// set hint to view data
				if($key == 1):
					$data['hint'] =  '<label>&nbsp; <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_100-200"> 100.000 - 200.000 </a> &nbsp; 
					   <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_200-300">200.000 - 300.000</a> &nbsp; 
							<a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_300-500"> 300.000 - 500.000 </a> &nbsp; 
							   <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_500"> > 500.000</a></label>';
					
					$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/price_range/1_100-200';
					$data['asc_name'] = 'LOW PRICE';
					$data['desc_name'] = 'HIGH PRICE';
				elseif($key == 2):
					$data['hint'] = '<label>&nbsp; <a href="#"> SALE SHOP </a> &nbsp; <a href="#"> REGULAR SHOP </a> </label>';
					$data['asc_name'] = 'LOW PRICE';
					$data['desc_name'] = 'HIGH PRICE';
				elseif($key == 3):
					$data['hint'] = '<label>&nbsp; <a href="#"> NEW COLLECTION </a> &nbsp; <a href="#"> BEST SELLER </a> </label>';
					$data['asc_name'] = 'LOW PRICE';
					$data['desc_name'] = 'HIGH PRICE';
					
				endif;
				
				// variabel filter
				$filter_var = $k[1];
				
				if($this->uri->segment(6) == 'index'):
					$this->load->library('pagination');
					$offset = $this->uri->segment(7);
					$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/index';
					$config['per_page'] = 12;
					$config['uri_segment'] = 7;
					$config['next_link'] = '&raquo;';
					$config['prev_link'] = '&laquo;';
					$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE));
					$this->pagination->initialize($config);
					
					$data['link'] = 'produk_brand_'.$id_brand;
					//function getProdukFilter($filter_name=FALSE,$filter_var=FALSE,$id_kat=FALSE,$id_brand=FALSE,$order_by=FALSE,$limit=FALSE,$offset=FALSE){
					$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,$config['per_page'],$offset);
					
					$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/price_range/'.$filter_var_key;
					$data['asc_name'] = 'LOW PRICE';
					$data['desc_name'] = 'HIGH PRICE';
					 //                             1    2    3        4         5     6   7   8
					//http://localhost/slackers/produk/brand/1/price_range/1_100-200/index/5/asc
					
					// FOR ORDER BY ==========================================================================
					if(($this->uri->segment(7) != '') && ($this->uri->segment(8) != '')):
						$this->load->library('pagination');
						$offset = $this->uri->segment(7);
						$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['per_page'] = 12;
						$config['uri_segment'] = 7;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE));
					   
						$this->pagination->initialize($config);
						$order_by = $this->uri->segment(8);
						$data['link'] = 'produk_brand_'.$id_brand;
						//function getProdukFilter($filter_name=FALSE,$filter_var=FALSE,$id_kat=FALSE,$id_brand=FALSE,$order_by=FALSE,$limit=FALSE,$offset=FALSE){
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,$config['per_page'],$offset);
						$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/price_range/'.$filter_var_key;
						$data['asc_name'] = 'LOW PRICE';
						$data['desc_name'] = 'HIGH PRICE';
						
					endif;
				else:
					$this->load->library('pagination');
					$offset = $this->uri->segment(8);
					$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
					$config['per_page'] = 12;
					$config['uri_segment'] = 8;
					$config['next_link'] = '&raquo;';
					$config['prev_link'] = '&laquo;';
					$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE));
					$this->pagination->initialize($config);
					
					$data['link'] = 'produk_brand_'.$id_brand;
					$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,$config['per_page'],$offset);
					
					if($key == 1):
						$data['hint'] =  '<label>&nbsp; <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_100-200"> 100.000 - 200.000 </a> &nbsp; 
						   <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_200-300">200.000 - 300.000</a> &nbsp; 
								<a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_300-500"> 300.000 - 500.000 </a> &nbsp; 
								   <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_500"> > 500.000</a></label>';
						if(!$offset):
							$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/price_range/'.$filter_var_key;
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						else:
							$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/price_range/'.$filter_var_key;
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						endif;
					elseif($key == 2):
						$data['hint'] = '<label>&nbsp; <a href="#"> SALE SHOP </a> &nbsp; <a href="#"> REGULAR SHOP </a> </label>';
						$data['asc_name'] = 'LOW PRICE';
						$data['desc_name'] = 'HIGH PRICE';
					elseif($key == 3):
						$data['hint'] = '<label>&nbsp; <a href="#"> NEW COLLECTION </a> &nbsp; <a href="#"> BEST SELLER </a> </label>';
						$data['asc_name'] = 'LOW PRICE';
						$data['desc_name'] = 'HIGH PRICE';
					endif;
				
				
				endif;
			   

			   $data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.$row_brand->nama_brand;
			   $data['title'] = $row_brand->nama_brand;

				// LINK use AJAX
			   // $data['link'] = 'produk_kategori_'.$id_brand.'_'.alias($row_brand->nama_brand);
				$data['main_view'] = 'slak/brand';
				$this->load->view('slak/index',$data);
				
/* ============================ FILTER FUNCTION TO SHORTING PRICE RANGE COMPLETE WITH PAGINATION FOR KATEGORI =======================================================*/			
			else: 
				$this->db->where('kategori_id',$id_kat);
				$query = $this->db->get('tb_kat_produk');
				$row = $query->row();

				// brand
				$this->db->where('brand_id',$id_brand);
				$row_brand = $this->db->get('tb_brand')->row();

				$qr = $this->db->get('tb_brand');
				$data['arr_brand'] = $qr->result_array();

				// HARD CODED FOR SLACKERS PRODUK
				if ($id_brand == 1):
						$data['page'] = 'produk_slaker';
				else:
						$data['page'] = 'produk';
						$data['brand_id'] = $id_brand;
				endif;
				
				// explode filter to get key short from helper
				
				$k = explode('_', $filter_var_key);
				
				$key = $k[0];
				
				// load to view data
				
				$data['key'] = $key;

				
				// set hint to view data
				
				if($key == 1):
					$data['hint'] =  '<label>&nbsp; <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_100-200"> 100.000 - 200.000 </a> &nbsp; 
					   <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_200-300">200.000 - 300.000</a> &nbsp; 
							<a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_300-500"> 300.000 - 500.000 </a> &nbsp; 
							   <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_500"> > 500.000</a></label>';
					
					$data['order_by_link'] = base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/'.$filter_var_key;
					$data['asc_name'] = 'LOW PRICE';
					$data['desc_name'] = 'HIGH PRICE';
				elseif($key == 2):
					$data['hint'] = '<label>&nbsp; <a href="'.base_url().''.$getLink.'/shopping_program/2_promo"> SALE SHOP </a> &nbsp; <a href="'.base_url().''.$getLink.'/shopping_program/2_regular"> REGULAR SHOP </a> </label>';
					$data['asc_name'] = 'LOW PRICE';
					$data['desc_name'] = 'HIGH PRICE';
				elseif($key == 3):
					$data['hint'] = '<label>&nbsp; <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/collection/3_new"> NEW COLLECTION </a> &nbsp; 
						<a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/collection/3_best"> BEST SELLER </a> </label>';
					$data['order_by_link'] = base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/collection/'.$filter_var_key;
						
					if($filter_var_key == '3_new'):
						$data['asc_name'] = 'NEWER';
						$data['desc_name'] = 'OLDER';
					elseif($filter_var_key == '3_best'):
						$data['asc_name'] = 'LOW PRICE';
						$data['desc_name'] = 'HIGH PRICE';
					endif;
					
				endif;
				// variabel filter
				$filter_var = $k[1];
				if($this->uri->segment(8)=='index'):
						$offset = $this->uri->segment(9);
						$config['per_page'] = 12;
						$config['uri_segment'] = 9 ;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						
						$this->pagination->initialize($config);
						
																   //getProdukFilter($filter_name=FALSE,$filter_var=FALSE,$id_kat=FALSE,$id_brand=FALSE,$order_by=FALSE,$limit=FALSE,$offset=FALSE){
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					// ORDER BY
				else:
					if(!$order_by):
						$offset = $this->uri->segment(9);
						$config['per_page'] = 12;
						$config['uri_segment'] = 9 ;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
						
																   //getProdukFilter($filter_name=FALSE,$filter_var=FALSE,$id_kat=FALSE,$id_brand=FALSE,$order_by=FALSE,$limit=FALSE,$offset=FALSE){
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					else:
						$offset = $this->uri->segment(10);
						$config['per_page'] = 12;
						$config['uri_segment'] = 10;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						
					   // $config['base_url'] = site_url().'produk/kategori/'.$id_kat.'/'.alias($row->nama_kategori).'/index/';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
					
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,$config['per_page'],$offset);
					endif;
				endif;
					$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.anchor('produk/brand/'.$row->brand_id,'<strong>'.$row_brand->nama_brand.'</strong>').' &raquo; '.$this->parent_kat_slug($id_kat);
					$data['title'] = $row->nama_kategori;

						// LINK use AJAX

					$data['link'] = 'produk_kategori_'.$id_brand.'_'.$id_kat.'_'.alias($row->nama_kategori);

						  
					$data['main_view'] = 'slak/kategori';
					$this->load->view('slak/index',$data);
			endif; 
			
/* ============================ FILTER FUNCTION TO SHORTING SHOPPING PROGRAM COMPLETE WITH PAGINATION =======================================================*/
	
		elseif($filter_name == 'shopping_program'):
/* ============================ FILTER FUNCTION TO SHORTING SHOPPING PROGRAM COMPLETE WITH PAGINATION FOR BRAND =======================================================*/
			if(!$id_kat): 

				// brand
				$this->db->where('brand_id',$id_brand);
				$row_brand = $this->db->get('tb_brand')->row();

				$qr = $this->db->get('tb_brand');
				$data['arr_brand'] = $qr->result_array();

				// HARD CODED FOR SLACKERS PRODUK
				if ($id_brand == 1):
					$data['page'] = 'produk_slaker';
				else:
					$data['page'] = 'produk';
					$data['brand_id'] = $id_brand;
				endif;
					
				// explode filter to get key short from helper
				$k = explode('_', $filter_var_key);
					
				$key = $k[0];
					
				// load to view data
					
				$data['key'] = $key;
		
				if($key == 1):
						$data['hint'] =  '<label>&nbsp; <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_100-200"> 100.000 - 200.000 </a> &nbsp; 
						   <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_200-300">200.000 - 300.000</a> &nbsp; 
								<a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_300-500"> 300.000 - 500.000 </a> &nbsp; 
								   <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_500"> > 500.000</a></label>';
						if(!$offset):
							$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/price_range/'.$filter_var_key;
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						else:
							$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/price_range/'.$filter_var_key;
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						endif;
				elseif($key == 2):
						$data['hint'] = '<label>&nbsp; <a href="'.base_url().'produk/brand/'.$id_brand.'/shopping_program/2_promo"> SALE SHOP </a> &nbsp; 
						
						<a href="'.base_url().'produk/brand/'.$id_brand.'/shopping_program/2_reguler"> REGULAR SHOP </a> </label>';
						
						$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/shopping_program/'.$filter_var_key;
						$data['asc_name'] = 'NEWER';
						$data['desc_name'] = 'OLDER';
		
				elseif($key == 3):
						$data['hint'] = '<label>&nbsp; <a href="'.base_url().'produk/brand/'.$id_brand.'/collection/3_new"> NEW COLLECTION </a> &nbsp; 
						<a href="'.base_url().'produk/brand/'.$id_brand.'/collection/3_best"> BEST SELLER </a> </label>';
						$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/collection/'.$filter_var_key;
						
						if($filter_var_key == '3_new'):
							$data['asc_name'] = 'NEWER';
							$data['desc_name'] = 'OLDER';
						elseif($filter_var_key == '3_best'):
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						endif;
						
				endif;
					
				$filter_var = $k[1];
				
				if($filter_var == 'promo'):

					if(!$order_by):
						$offset = $this->uri->segment(8);
						$config['per_page'] = 12;
						$config['uri_segment'] = 8;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);	
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,$config['per_page'],$offset);
					
					elseif($this->uri->segment(6)=='index'):
						$offset = $this->uri->segment(7);
						$config['per_page'] = 12;
						$config['uri_segment'] = 7;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
							
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,$config['per_page'],$offset);
					
					else:
							$offset = $this->uri->segment(8);
							$config['per_page'] = 12;
							$config['uri_segment'] = 8;
							$config['next_link'] = '&raquo;';
							$config['prev_link'] = '&laquo;';
							$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
							$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,FALSE,FALSE,FALSE));
							$this->pagination->initialize($config);
								
							$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,$config['per_page'],$offset);
					endif;	
				elseif($filter_var == 'reguler'):
					if(!$order_by):
						$offset = $this->uri->segment(8);
						$config['per_page'] = 12;
						$config['uri_segment'] = 8;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);	
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,$config['per_page'],$offset);
					
					elseif($this->uri->segment(6)=='index'):
						$offset = $this->uri->segment(7);
						$config['per_page'] = 12;
						$config['uri_segment'] = 7;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
							
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,$config['per_page'],$offset);
					
					else:
							$offset = $this->uri->segment(8);
							$config['per_page'] = 12;
							$config['uri_segment'] = 8;
							$config['next_link'] = '&raquo;';
							$config['prev_link'] = '&laquo;';
							$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
							$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,FALSE,FALSE,FALSE));
							$this->pagination->initialize($config);
								
							$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,$config['per_page'],$offset);
					endif;
				endif;
				
				$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.$row_brand->nama_brand;
			    $data['title'] = $row_brand->nama_brand;

				// LINK use AJAX
			    $data['link'] = 'produk_brand_'.$id_brand;

			  
				$data['main_view'] = 'slak/brand';
				$this->load->view('slak/index',$data);
				
/* ============================ FILTER FUNCTION TO SHORTING SHOPPING PROGRAM COMPLETE WITH PAGINATION FOR KATEGORI =======================================================*/
	
			else: 
				$this->db->where('kategori_id',$id_kat);
				$query = $this->db->get('tb_kat_produk');
				$row = $query->row();

				// brand
				$this->db->where('brand_id',$id_brand);
				$row_brand = $this->db->get('tb_brand')->row();

				$qr = $this->db->get('tb_brand');
				$data['arr_brand'] = $qr->result_array();

				// HARD CODED FOR SLACKERS PRODUK
				if ($id_brand == 1):
					$data['page'] = 'produk_slaker';
				else:
					$data['page'] = 'produk';
					$data['brand_id'] = $id_brand;
				endif;
					
				// explode filter to get key short from helper
					
				$k = explode('_', $filter_var_key);
					
				$key = $k[0];
					
				// load to view data
					
				$data['key'] = $key;
		
				if($key == 1):
						$data['hint'] =  '<label>&nbsp; <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_100-200"> 100.000 - 200.000 </a> &nbsp; 
						   <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_200-300">200.000 - 300.000</a> &nbsp; 
								<a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_300-500"> 300.000 - 500.000 </a> &nbsp; 
								   <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_500"> > 500.000</a></label>';
						
						$data['order_by_link'] = base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/'.$filter_var_key;
						$data['asc_name'] = 'LOW PRICE';
						$data['desc_name'] = 'HIGH PRICE';
				elseif($key == 2):
						$data['hint'] = '<label>&nbsp; <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/shopping_program/2_promo"> SALE SHOP </a> &nbsp; 
						
						<a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/shopping_program/2_reguler"> REGULAR SHOP </a> </label>';
						
						$data['order_by_link'] = base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/shopping_program/'.$filter_var_key;
						$data['asc_name'] = 'NEWER';
						$data['desc_name'] = 'OLDER';
		
				elseif($key == 3):
						$data['hint'] = '<label>&nbsp; <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/collection/3_new"> NEW COLLECTION </a> &nbsp; 
						<a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/collection/3_best"> BEST SELLER </a> </label>';
						$data['order_by_link'] = base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/collection/'.$filter_var_key;
						
						if($filter_var_key == '3_new'):
							$data['asc_name'] = 'NEWER';
							$data['desc_name'] = 'OLDER';
						elseif($filter_var_key == '3_best'):
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						endif;
						
				endif;
					
				$filter_var = $k[1];
				
				if($filter_var == 'promo'):

					if(!$order_by):
						$offset = $this->uri->segment(10);
						$config['per_page'] = 12;
						$config['uri_segment'] = 10;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);	
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					
					elseif($this->uri->segment(8)=='index'):
						$offset = $this->uri->segment(9);
						$config['per_page'] = 12;
						$config['uri_segment'] = 9;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
							
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					
					else:
							$offset = $this->uri->segment(10);
							$config['per_page'] = 12;
							$config['uri_segment'] = 10;
							$config['next_link'] = '&raquo;';
							$config['prev_link'] = '&laquo;';
							$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
							$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,FALSE,FALSE,FALSE));
							$this->pagination->initialize($config);
								
							$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,$config['per_page'],$offset);
					endif;	
				elseif($filter_var == 'reguler'):
					if(!$order_by):
						$offset = $this->uri->segment(10);
						$config['per_page'] = 12;
						$config['uri_segment'] = 10;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);	
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					
					elseif($this->uri->segment(8)=='index'):
						$offset = $this->uri->segment(9);
						$config['per_page'] = 12;
						$config['uri_segment'] = 9;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
							
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					
					else:
							$offset = $this->uri->segment(10);
							$config['per_page'] = 12;
							$config['uri_segment'] = 10;
							$config['next_link'] = '&raquo;';
							$config['prev_link'] = '&laquo;';
							$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
							$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,FALSE,FALSE,FALSE));
							$this->pagination->initialize($config);
								
							$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,$config['per_page'],$offset);
					endif;
				endif;
				
				$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.anchor('produk/brand/'.$row->brand_id,'<strong>'.$row_brand->nama_brand.'</strong>').' &raquo; '.$this->parent_kat_slug($id_kat);
				$data['title'] = $row->nama_kategori;

				// LINK use AJAX

				$data['link'] = 'produk_kategori_'.$id_brand.'_'.$id_kat.'_'.alias($row->nama_kategori);

							  
				$data['main_view'] = 'slak/kategori';
				$this->load->view('slak/index',$data);
			endif;

/* ============================ FILTER FUNCTION TO SHORTING COLLECTION COMPLETE WITH PAGINATION  =======================================================*/

		elseif($filter_name == 'collection'):
/* ============================ FILTER FUNCTION TO SHORTING COLLECTION COMPLETE WITH PAGINATION FOR BRAND =======================================================*/
			if(!$id_kat): 

				// brand
				$this->db->where('brand_id',$id_brand);
				$row_brand = $this->db->get('tb_brand')->row();

				$qr = $this->db->get('tb_brand');
				$data['arr_brand'] = $qr->result_array();

				// HARD CODED FOR SLACKERS PRODUK
				if ($id_brand == 1):
					$data['page'] = 'produk_slaker';
				else:
					$data['page'] = 'produk';
					$data['brand_id'] = $id_brand;
				endif;
					
				// explode filter to get key short from helper
					
				$k = explode('_', $filter_var_key);
					
				$key = $k[0];
					
				// load to view data
					
				$data['key'] = $key;
		
				if($key == 1):
						$data['hint'] =  '<label>&nbsp; <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_100-200"> 100.000 - 200.000 </a> &nbsp; 
						   <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_200-300">200.000 - 300.000</a> &nbsp; 
								<a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_300-500"> 300.000 - 500.000 </a> &nbsp; 
								   <a href="'.base_url().'produk/brand/'.$id_brand.'/price_range/1_500"> > 500.000</a></label>';
						if(!$offset):
							$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/price_range/'.$filter_var_key;
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						else:
							$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/price_range/'.$filter_var_key;
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						endif;
				elseif($key == 2):
						$data['hint'] = '<label>&nbsp; <a href="'.base_url().'produk/brand/'.$id_brand.'/shopping_program/2_promo"> SALE SHOP </a> &nbsp; 
						<a href="'.base_url().'produk/brand/'.$id_brand.'/shopping_program/2_reguler"> REGULAR SHOP </a> </label>';
						
						$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/shopping_program/'.$filter_var_key;
						$data['asc_name'] = 'NEWER';
						$data['desc_name'] = 'OLDER';
		
				elseif($key == 3):
						$data['hint'] = '<label>&nbsp; <a href="'.base_url().'produk/brand/'.$id_brand.'/collection/3_new"> NEW COLLECTION </a> &nbsp; 
						<a href="'.base_url().'produk/brand/'.$id_brand.'/collection/3_best"> BEST SELLER </a> </label>';
						$data['order_by_link'] = base_url().'produk/brand/'.$id_brand.'/collection/'.$filter_var_key;
						
						if($filter_var_key == '3_new'):
							$data['asc_name'] = 'NEWER';
							$data['desc_name'] = 'OLDER';
						elseif($filter_var_key == '3_best'):
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						endif;
				endif;
					
				$filter_var = $k[1];
				
				if($filter_var == 'new'):

					if(!$order_by):
						$offset = $this->uri->segment(8);
						$config['per_page'] = 12;
						$config['uri_segment'] = 8;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);	
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,$config['per_page'],$offset);
					
					elseif($this->uri->segment(6)=='index'):
						$offset = $this->uri->segment(7);
						$config['per_page'] = 12;
						$config['uri_segment'] = 7;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
							
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,$config['per_page'],$offset);
					
					else:
							$offset = $this->uri->segment(8);
							$config['per_page'] = 12;
							$config['uri_segment'] = 8;
							$config['next_link'] = '&raquo;';
							$config['prev_link'] = '&laquo;';
							$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
							$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,FALSE,FALSE,FALSE));
							$this->pagination->initialize($config);
								
							$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,$config['per_page'],$offset);
					endif;	
				elseif($filter_var == 'best'):
					if(!$order_by):
						$offset = $this->uri->segment(8);
						$config['per_page'] = 12;
						$config['uri_segment'] = 8;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);	
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,$config['per_page'],$offset);
					
					elseif($this->uri->segment(6)=='index'):
						$offset = $this->uri->segment(7);
						$config['per_page'] = 12;
						$config['uri_segment'] = 7;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
							
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,FALSE,$config['per_page'],$offset);
					
					else:
							$offset = $this->uri->segment(8);
							$config['per_page'] = 12;
							$config['uri_segment'] = 8;
							$config['next_link'] = '&raquo;';
							$config['prev_link'] = '&laquo;';
							$config['base_url'] = site_url().'produk/brand/'.$id_brand.'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
							$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,FALSE,FALSE,FALSE));
							$this->pagination->initialize($config);
								
							$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,FALSE,$id_brand,$order_by,$config['per_page'],$offset);
					endif;
				endif;
				
				$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.$row_brand->nama_brand;
			    $data['title'] = $row_brand->nama_brand;

				// LINK use AJAX

			    $data['link'] = 'produk_brand_'.$id_brand;

			  
				$data['main_view'] = 'slak/brand';
				$this->load->view('slak/index',$data);
				
				
			else: // FOR KATEGORI ======================================================================================================
				$this->db->where('kategori_id',$id_kat);
				$query = $this->db->get('tb_kat_produk');
				$row = $query->row();

				// brand
				$this->db->where('brand_id',$id_brand);
				$row_brand = $this->db->get('tb_brand')->row();

				$qr = $this->db->get('tb_brand');
				$data['arr_brand'] = $qr->result_array();

				// HARD CODED FOR SLACKERS PRODUK
				if ($id_brand == 1):
					$data['page'] = 'produk_slaker';
				else:
					$data['page'] = 'produk';
					$data['brand_id'] = $id_brand;
				endif;
					
				// explode filter to get key short from helper
					
				$k = explode('_', $filter_var_key);
					
				$key = $k[0];
					
				// load to view data
					
				$data['key'] = $key;
		
				if($key == 1):
						$data['hint'] =  '<label>&nbsp; <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_100-200"> 100.000 - 200.000 </a> &nbsp; 
						   <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_200-300">200.000 - 300.000</a> &nbsp; 
								<a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_300-500"> 300.000 - 500.000 </a> &nbsp; 
								   <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/1_500"> > 500.000</a></label>';
						
						$data['order_by_link'] = base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/price_range/'.$filter_var_key;
						$data['asc_name'] = 'LOW PRICE';
						$data['desc_name'] = 'HIGH PRICE';
				elseif($key == 2):
						$data['hint'] = '<label>&nbsp; <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/shopping_program/2_promo"> SALE SHOP </a> &nbsp; 
						
						<a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/shopping_program/2_reguler"> REGULAR SHOP </a> </label>';
						
						$data['order_by_link'] = base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/shopping_program/'.$filter_var_key;
						$data['asc_name'] = 'NEWER';
						$data['desc_name'] = 'OLDER';
		
				elseif($key == 3):
						$data['hint'] = '<label>&nbsp; <a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/collection/3_new"> NEW COLLECTION </a> &nbsp; 
						<a href="'.base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/collection/3_best"> BEST SELLER </a> </label>';
						$data['order_by_link'] = base_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/collection/'.$filter_var_key;
						
						if($filter_var_key == '3_new'):
							$data['asc_name'] = 'NEWER';
							$data['desc_name'] = 'OLDER';
						elseif($filter_var_key == '3_best'):
							$data['asc_name'] = 'LOW PRICE';
							$data['desc_name'] = 'HIGH PRICE';
						endif;
						
				endif;
					
				$filter_var = $k[1];
				
				if($filter_var == 'new'):

					if(!$order_by):
						$offset = $this->uri->segment(10);
						$config['per_page'] = 12;
						$config['uri_segment'] = 10;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);	
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					
					elseif($this->uri->segment(8)=='index'):
						$offset = $this->uri->segment(9);
						$config['per_page'] = 12;
						$config['uri_segment'] = 9;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
							
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					
					else:
							$offset = $this->uri->segment(10);
							$config['per_page'] = 12;
							$config['uri_segment'] = 10;
							$config['next_link'] = '&raquo;';
							$config['prev_link'] = '&laquo;';
							$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
							$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,FALSE,FALSE,FALSE));
							$this->pagination->initialize($config);
								
							$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,$config['per_page'],$offset);
					endif;	
				elseif($filter_var == 'best'):
					if(!$order_by):
						$offset = $this->uri->segment(10);
						$config['per_page'] = 12;
						$config['uri_segment'] = 10;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);	
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					
					elseif($this->uri->segment(8)=='index'):
						$offset = $this->uri->segment(9);
						$config['per_page'] = 12;
						$config['uri_segment'] = 9;
						$config['next_link'] = '&raquo;';
						$config['prev_link'] = '&laquo;';
						$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/index';
						$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,FALSE,FALSE,FALSE));
						$this->pagination->initialize($config);
							
						$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,FALSE,$config['per_page'],$offset);
					
					else:
							$offset = $this->uri->segment(10);
							$config['per_page'] = 12;
							$config['uri_segment'] = 10;
							$config['next_link'] = '&raquo;';
							$config['prev_link'] = '&laquo;';
							$config['base_url'] = site_url().'produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori).'/'.$filter_name.'/'.$filter_var_key.'/'.$order_by.'/index';
							$config['total_rows'] = count($this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,FALSE,FALSE,FALSE));
							$this->pagination->initialize($config);
								
							$data['arr_produk'] = $this->Produk_model->getProdukFilter($filter_name,$filter_var,$id_kat,$id_brand,$order_by,$config['per_page'],$offset);
					endif;
				endif;
				
				$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.anchor('produk/brand/'.$row->brand_id,'<strong>'.$row_brand->nama_brand.'</strong>').' &raquo; '.$this->parent_kat_slug($id_kat);
				$data['title'] = $row->nama_kategori;

				// LINK use AJAX

				$data['link'] = 'produk_kategori_'.$id_brand.'_'.$id_kat.'_'.alias($row->nama_kategori);

							  
				$data['main_view'] = 'slak/kategori';
				$this->load->view('slak/index',$data);
			endif;
			
	
        endif;
		

		
	}
	
	function view()
	{
		$data['current2'] = 'current'; // FOR MENU
		$id_kat=$this->uri->segment(4);
		$id_brand=$this->uri->segment(3);
		$id_prod=$this->uri->segment(5);
		
		
		$this->db->where('kategori_id',$id_kat);
		$query = $this->db->get('tb_kat_produk');
		$row = $query->row();
		
				
		$this->db->where('brand_id',$id_brand);
		$query = $this->db->get('tb_brand');
		$row_b = $query->row();
		
		
		$qr = $this->db->get('tb_brand');
		$data['arr_brand'] = $qr->result_array();
		
		// HARD CODED FOR SLACKERS PRODUK
		if ($row->brand_id == 1):
			$data['page'] = 'produk_slaker';
		else:
			$data['page'] = 'produk';
			$data['brand_id'] = $row->brand_id;
		endif;

        // QUERY IMAGE PRODUK DIRECT
		$this->db->where('produk_id',$id_prod);
		$data['arr_image'] = $this->db->get('tb_image_produk')->result_array();
	
		// QUERY GET FAVORITE PRODUK
		
		$qr_fav = $this->db->query('
			SELECT 
			pr.produk_id,
			pr.nama_produk,
			pr.prod_brand_id,
			pr.harga,
			pr.persen_diskon,
			pr.prod_kat_id,
			pr.deskripsi,
			img.produk_img_thumb,
			count(pr.produk_id) AS count_pr
			FROM tb_wishlist ws
			INNER JOIN tb_produk pr ON pr.produk_id = ws.produk_id
			INNER JOIN tb_image_produk img ON img.image_produk_id = ws.produk_id
			WHERE img.look = 1
			GROUP BY pr.produk_id
			ORDER BY count_pr DESC LIMIT 4
		');
		$data['arr_produk_fav'] = $qr_fav->result_array();
		
		
		//GET THE PROMO
		$data['arr_promo'] = $this->Produk_model->getProduk('promo_produk_view',FALSE,FALSE,FALSE,FALSE,FALSE);
		
		$data['row'] = $this->Produk_model->getProduk('prod_ready',$id_prod,FALSE,FALSE,FALSE,FALSE);
		$data['title'] = $data['row']->nama_produk;
		$data['ses_id'] = $this->session->userdata('session_id');
		$max = $data['row']->harga + 10000;
		$min = $data['row']->harga - 10000;
		$data['related'] = $this->Produk_model->getRelatedProducts($id_kat,$id_prod,$max,$min);
		
		$data['count_rel'] = count($this->Produk_model->getRelatedProducts($id_kat,$id_prod,$max,$min));
		
		$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; '.anchor('produk/brand/'.$id_brand,'<strong>'.$row_b->nama_brand.'</strong>').' &raquo; '.anchor('produk/kategori/'.$id_brand.'/'.$id_kat.'/'.alias($row->nama_kategori),'<strong>'.$row->nama_kategori.'</strong>').' &raquo; '.$data['row']->nama_produk;

		
		$data['main_view'] = 'slak/view_produk';
		$this->load->view('slak/index',$data);
		
	}
	
	function review()
	{
		$this->form_validation->set_rules('nama', 'Nama', 'required');
		$this->form_validation->set_rules('isi_review', 'Isi', 'required');
		$this->form_validation->set_rules('rating', 'Rating', 'required');
		$this->form_validation->set_rules('number', 'Captcha Number', 'required');

		if ($this->form_validation->run() == FALSE):
			$id_cat = $this->input->post('id_kat');
			$id_prod = $this->input->post('id_prod');
			$msg = $this->session->userdata('session_id').'4';
			redirect('produk/view/'.$id_cat.'/'.$id_prod.'/'.$msg,'refresh');
		else:
			
			$id_cat = $this->input->post('id_kat');
			$id_prod = $this->input->post('id_prod');
			
			session_start();
			$key=substr($_SESSION['key'],0,6);
			$number = $this->input->post('number');
			if($number!=$key):
				$msg = $this->session->userdata('session_id').'3';
				redirect('produk/view/'.$id_cat.'/'.$id_prod.'/'.$msg,'refresh');
			else:
				$ses_id = $this->session->userdata('session_id');
				$this->db->where('rev_prod_id',$id_prod);
				$this->db->where('ses_id',$ses_id);
				$qr = $this->db->get('tb_review');
				
				if ($qr->num_rows() == 0):
					$data = array('nama' => $this->input->post('nama'),
								  'rev_prod_id' => $id_prod,
								  'isi_review' => $this->input->post('isi_review'),
								  'rating' => $this->input->post('rating'),
								  'date' => date("Y-m-d h:i:s"),
								  'status' => 'unapprove',
								  'ses_id' => $ses_id
								  );  
					
					$this->Produk_model->addReview($data);
					$msg = $this->session->userdata('session_id').'1';
					redirect('produk/view/'.$id_cat.'/'.$id_prod.'/'.$msg,'refresh');
				else:
					$msg = $this->session->userdata('session_id').'2';
					redirect('produk/view/'.$id_cat.'/'.$id_prod.'/'.$msg,'refresh');
				endif;
			endif;
		endif;
	}
	
	function all_review()
	{
		$data['current2'] = 'current'; // FOR MENU
		$prod_id = $this->uri->segment(3);
		$this->load->library('pagination');
		$offset = $this->uri->segment(4);
		$config['base_url'] = site_url().'/produk/all_review/'.$prod_id;
		$config['total_rows'] = count($this->Produk_model->getReview('by_produk',FALSE,$prod_id,FALSE,FALSE));
		$config['per_page'] = 12;
		$config['uri_segment'] = 4;
		$config['next_link'] = '&raquo;';
		$config['prev_link'] = '&laquo;';
		$data['ses_id'] = $this->session->userdata('session_id');
		$title = $this->Produk_model->getProduk(FALSE,$prod_id,FALSE,FALSE)->nama_produk;
		$data['title'] = 'Review Produk '.$title;
		$data['review'] = $this->Produk_model->getReview('by_produk',FALSE,$prod_id,$config['per_page'],$offset);
		$this->pagination->initialize($config);
		$data['main_view'] = 'all_review';
		$this->load->view('/index',$data);
	}
	
	function pencarian()
	{
		$this->form_validation->set_rules('cari_prod', 'Masukan Produk', 'required');
		if ($this->form_validation->run() == FALSE):
			redirect('produk');
		else:
			$cari_prod = $this->input->post('cari_prod');
			$this->load->library('pagination');
			$config['base_url'] = site_url().'/produk/pencarian/index';
			$config['total_rows'] = count($this->Produk_model->getcariProduk($cari_prod,FALSE,FALSE,FALSE));
			$config['per_page'] = 8;
			$config['uri_segment'] = 3;
			$config['next_link'] = '&raquo;';
			$config['prev_link'] = '&laquo;';
			$this->pagination->initialize($config);
			$data['ses_id'] = $this->session->userdata('session_id');
			$data['res_prod'] = $this->Produk_model->getcariProduk($cari_prod,FALSE,$config['per_page'],$this->uri->segment(4));
			$data['cumb'] = anchor('produk','<strong>Home</strong>').' &raquo; Hasil Pencarian';
			$data['title'] = 'Hasil Pencarian';
			$data['main_view'] = 'pencarian';
			$this->load->view('/index',$data);
		endif;
	}
	
	function konfirmasi()
	{
		$this->form_validation->set_rules('no_order', 'Masukan No Order', 'required');
		if ($this->form_validation->run() == FALSE):
			redirect('produk');
		else:
			$data['ses_id'] = $this->session->userdata('session_id');
			$no_order = md5($this->input->post('no_order'));
			
			
			$data['order'] = $this->Order_model->getOrderBy('by_code',FALSE,$no_order);
			if(!empty($data['order'])):
				$data['cumb'] = anchor('produk','<strong>Home</strong>').' &raquo; Hasil Konfirmasi';
				$order_id = $data['order']->order_id;
				$data['det_order'] = $this->Order_model->getOrderDetailById($order_id);
				$data['title'] = 'Hasil Konfirmasi';
				$data['key_order'] = md5($data['order']->order_code);
				$data['main_view'] = 'konf';
				$this->load->view('/index',$data);
			else:
				$data['title'] = 'Hasil Konfirmasi';
				$data['main_view'] = 'no_konf';
				$this->load->view('/index',$data);
			endif;
		endif;
	}
        
        function ajax_sort() {
            
            $sort_id = $this->uri->segment(3);
            $link = $this->uri->segment(4);
            
            $getLink = str_replace("_","/",$link);
            
            if($sort_id == 1):
                echo '<label>&nbsp; <a href="'.base_url().''.$getLink.'/price_range/1_100-200"> 100.000 - 200.000 </a> &nbsp; <a href="'.base_url().''.$getLink.'/price_range/1_200-300">200.000 - 300.000</a> &nbsp; <a href="'.base_url().''.$getLink.'/price_range/1_300-500"> 300.000 - 500.000 </a> &nbsp; <a href="'.base_url().''.$getLink.'/price_range/1_500"> > 500.000</a></label>';
            elseif($sort_id == 2):
                echo '<label>&nbsp; <a href="'.base_url().''.$getLink.'/shopping_program/2_promo"> SALE SHOP </a> &nbsp; <a href="'.base_url().''.$getLink.'/shopping_program/2_reguler"> REGULAR SHOP </a> </label>';
            elseif($sort_id == 3):
                echo '<label>&nbsp; <a href="'.base_url().''.$getLink.'/collection/3_new"> NEW COLLECTION </a> &nbsp; <a href="'.base_url().''.$getLink.'/collection/3_best"> BEST SELLER </a> </label>';
                
            endif;
            
        }
        
    
	
}



/* End of file welcome.php */
/* Location: ./system/application/controllers/home.php */